package com.chenc.javathreads.controlleraop.config;

import com.chenc.javathreads.controlleraop.intercetor.GolbalNoInterceptor;
import com.chenc.javathreads.controlleraop.intercetor.LogInterceptor;
import com.chenc.javathreads.controlleraop.intercetor.SignApiInteceptor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @ClassName
 * @Describtion:
 * @Author:Chenc
 * @Date:2023/12/18 15:22
 * @Version 1.0
 */
@Configuration
public class WebConfig implements WebMvcConfigurer{

    @Resource
    LogInterceptor logInterceptor;
    @Resource
    GolbalNoInterceptor golbalNoInterceptor;
    @Resource
    SignApiInteceptor signApiInteceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(golbalNoInterceptor).addPathPatterns("/**");
        registry.addInterceptor(logInterceptor).addPathPatterns("/**").excludePathPatterns("/cqk/error");
        registry.addInterceptor(signApiInteceptor).addPathPatterns("/cqk/api/**").excludePathPatterns("/cqk/error");
        //这边的path实际是 urlpath
    }

//    @Bean(name = "ObjectMapper")
//    public ObjectMapper getObjectMapper(){
//        return new ObjectMapper();
//    }
}
